/**
 * @Author ZhangCuirong
 * @Date 2025/8/4 21:10
 * @description:
 */
public class Solution415 {
    public String addStrings(String num1, String num2) {
        int i = num1.length() - 1;
        int j = num2.length() - 1;
        int carry = 0;
        StringBuilder res = new StringBuilder();
        while (i >= 0 || j >= 0 || carry!=0) {
            int x = i >= 0 ? num1.charAt(i) - '0' : 0;
            i--;
            int y = j >= 0 ? num2.charAt(j) - '0' : 0;
            j--;
            int sum = (x + y + carry) % 10;
            carry = (x + y + carry) / 10;
            res.append(sum);
        }
        return res.reverse().toString();
    }

    public static void main(String[] args) {
        Solution415 solution = new Solution415();
        String num1 = "11";
        String num2 = "123";
        String res = solution.addStrings(num1, num2);
        System.out.println(res);
    }
}
